package com.numbfish.ch41_ex01_oauth2_server.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.net.http.HttpRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class LoginController {
    @GetMapping("/login")
    public String login() {
        return "login";
    }

    @GetMapping("/hello")
    public String hello() {
        System.out.println("hello process");
        return "hello";
    }

    @GetMapping("/client-form")
    public String clientForm() {
        System.out.println("client-form");
        return "client-form";
    }

    @PostMapping("/client-form-submit")
    @ResponseBody
    public Map<String, String[]> clientFormSubmit(HttpServletRequest request) {
        Map<String, String[]> parameterMap = request.getParameterMap();
        return parameterMap;
    }

    @GetMapping("/forwardFrom")
    public String forwardFrom() {
        return "redirect:/forwardTo";
    }

    @GetMapping("/forwardTo")
    public String forwardTo() {
        return "forward-to";
    }
}
